﻿using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace WebApplicationHook
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Hook" in code, svc and config file together.
    public class Hook : IHook
    {
        HookWorkflow hookWorkflow = new HookWorkflow();

        public void Publish(string channel, int taskType)
        {
            hookWorkflow.Publish(channel, taskType);
        }

        #region IHook Members


        public bool RegisterSubscriber(string channelName, string subscriberId)
        {
            return hookWorkflow.RegisterSubscriber(channelName, subscriberId);
        }

        public bool UnRegisterSubscriber(string channelName, string subscriberId)
        {
            return hookWorkflow.UnRegisterSubscriber(channelName, subscriberId);
        }

        #endregion

        #region IHook Members


        public void LoadChannel()
        {
            hookWorkflow.LoadChannel();
        }

        #endregion

        //#region IHook Members


        public void ReceiveEmail(string channel)
        {
            hookWorkflow.SendEmail(channel);
        }

        //#endregion

        #region IHook Members


        public void ScreenShot(string channel)
        {
           hookWorkflow.ScreenShot(channel);
        }

        #endregion

        #region IHook Members


        public void SendScreenShot(byte[] bytes)
        {
            string fileName = Guid.NewGuid().ToString();

            var fs = new BinaryWriter(new FileStream(@"D:\\accordion\\" + fileName + ".jpeg", FileMode.Append, FileAccess.Write));
            fs.Write(bytes);
            fs.Close();
        }

        #endregion
    }
}
